<template>
  <div class="app">
    <!-- <div class="searchbox">
        <input type="text" placeholder="搜索商家、商品名称" v-model="searchText">
        <span @click="shopsearch">搜索</span>
    </div> -->
    <div class="like">
        <div class="choice" >
            <span v-for="(item,index) in likeArr" :key="index" @click="handleClick(item,index)" :class="{active: currentIndex == index }">{{item}}</span>
        </div>
        <div class="type" >
            <span v-for="(item,index) in typeArr" :key="index">{{item}}</span>
        </div>
    </div>
    <!-- 列表 -->
    <div class="good">
    <div class="xinxi"  v-for="(item,index) in searchlist" :key="index" @click="toDetail(item)">
      <div class="imgbox">
        <img :src="item.picUrl" alt="" />
      </div>
      <div class="dian">
        <div class="title">{{item.name}}</div>
        <div class="psh">
          <span>{{item.wmPoiScore}}</span>
          <span>{{item.monthSalesTip}}</span>
        </div>
        <div class="song">
          <div class="qisong">
            <span>{{item.minPriceTip}}</span>
            <span>{{item.shippingFeeTip}}</span>
          </div>
          <div class="min">
            <span>{{item.deliveryTimeTip}}</span>
            <span>{{item.distance}}</span>
          </div>
        </div>
        <div class="pjia">
          <span></span>
        </div>
        <div class="jian">
          <span v-for="(item,index) in item.discounts2" :key="index">{{item.info}}</span>
        </div>
      </div>
    </div>
  </div>
  </div>
</template>

<script>
import { mapState,mapMutations} from 'vuex'
export default {
  data(){
      return {
          currentIndex:0,
          likeArr:['综合排序','距离最近','销量最高','筛选'],
          typeArr:['年货节热卖','津贴联盟'],
          // list:[],
      }
    },
    computed:{
        ...mapState(['searchArr']),
        ...mapState(['searchlist']),
    // ...mapMutations(['collect','cancel_collect']),
    },
    mounted(){
      // if(searchlist.length == 0){
      //   Dialog.alert({
      //     title: '标题',
      //     message: '弹窗内容',
      //     }).then(() => {
      //     // on close
      //     });
      // }
    },
    
    methods:{
      handleClick(item,index){
          this.currentIndex = index;
          if(index == 1){
              this.searchlist.sort((a,b)=>{
              // console.log(a.distance);
              return a.wmPoiScore - b.wmPoiScore;
              })
          }else if(index == 2){
              this.searchlist.sort((a,b)=>{
              // console.log(a.monthSalesTip);
                  return b.wmPoiScore - a.wmPoiScore;
              })
          }
      },
      toDetail(item){
            this.$router.push('/detail/'+item.mtWmPoiId);
        }
    },
}
</script>

<style lang="scss" scoped>
.like{

    margin:10px 0;
    flex-wrap: wrap;
}
.like .choice{
    display: flex;
    justify-content: space-around;
}
.like .choice span.active{
    color:#3cbdff;
}
.like .type{
    margin: 10px 0;
}
.like .type span{
    padding: 0 5px;
    background-color: #f5f5f5;
    margin: 0 5px;
}
.list .shop{
    margin: 10px;
    display: flex;
    // justify-content: space-around;
    // float: left;
}
/* 店铺信息 */
.xinxi {
  box-sizing: border-box;
  display: flex;
  padding: 0 10px;
  padding-bottom: 20px;
  
}

.xinxi .imgbox {
  height: 100px;
  margin-right: 10px;
}

.xinxi .imgbox img {
  height: 100%;
}

/* 店铺详细信息 */
.xinxi .dian {
  display: flex;
  flex-direction: column;
}

/* 店铺名称 */
.xinxi .dian .title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 15px;
}

/* 月售 */
.xinxi .dian .psh {
  font-size: 12px;
  color: #999;
  margin-bottom: 5px;
}

.xinxi .dian .psh span {
  display: inline-block;
  margin-right: 5px;
}

.xinxi .dian .psh span:nth-child(1) {
  color: red;
}

/* 配送 */
.xinxi .dian .song {
  color: #999;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.xinxi .dian .song .qisong {
  flex: 1;
  margin-right: 10px;
}

.xinxi .dian .song .qisong span:nth-child(3) {
  font-size: 6px;
  color: #999;
  text-decoration: line-through;
}

.xinxi .dian .song span {
  display: inline-block;
  margin-right: 2px;
}

/* 评价 */
.xinxi .dian .pjia {
  font-size: 10px;
  color: orange;
  margin-bottom: 5px;
}

.xinxi .dian .pjia span {
  background-color: rgb(226, 210, 181);
  margin-right: 4px;
  border-radius: 4px;
}

/* 满减 */

.xinxi .dian .jian {
  display: flex;
  font-size: 10px;
}
.xinxi .dian .jian span {
  font-size: 8px;
  margin: 6px 0;
  color: red;
  border: 1px solid red;
  display: inline-block;
  margin-right: 5px;
  border-radius: 4px;
}

/* 排序点击后样式的变化 */
.bol {
  font-weight: bold;
}
</style>